<%--
Created by IntelliJ IDEA.
User: zhangxt
Date: 2024/10/11
Time: 21:46
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%request.setCharacterEncoding("utf-8");%>
<% String id=request.getParameter("stuid");%>
<html>
<head>
    <title>修改结果</title>
    <%!ResultSet rs;%>
    <%
    String dbName = "jdbc";
    String userName="root";
    String userPasswd="123456";
    String url="jdbc:mysql://localhost/"+ dbName +"?user="+userName+"&password="+userPasswd;
    Class.forName("com.mysql.jdbc.Driver");
    Connection conn = DriverManager.getConnection(url);
    String sql ="DELETE from student where id =?";
    PreparedStatement preparedStatement=conn.prepareStatement(sql);
    preparedStatement.setString(1,id);
    int result=preparedStatement.executeUpdate();
    if(result>0)
    out.print("<script type='text/javascript'>alert('删除成功');</script");
else
out.print("<script type='text/javascript'>alert('删除失败');</script");
sql ="select *from student";
rs=preparedStatement.executeQuery(sql);
%>
</head>
<body>
<table border="1">
    <th colspan="4" style="font-size:x-large;alignment: center">学生信息表</th>
    <tr style="text-align: center">
        <td>学号</td>
        <td>姓名</td>
        <td>出生日期</td>
        <td>所在班级</td>
    </tr>
    <% while (rs.next()){  %>
    <tr style="text-align: center">
    <td><%=rs.getString("stuid")  %></td>
    <td><%=rs.getString("stuname")  %></td>
    <td><%=rs.getString("birthday")  %></td>
    <td><%=rs.getString("stuclass")  %></td>
    </tr>
    <%  }  %>
    <%
    rs.close();
    preparedStatement.close();
    conn.close();
    %>
</body>
</html>